<template>
	<view class="wrap">
		<view class="topBc"></view>
		<view class="content formLengthWrap">
			<view class="title" style="margin-top: 0;">外商投资基本情况</view>
			
			<u-form :model="formData" ref="uForm" :rules="rules">
				
				<u-form-item v-if="formKeys.enentname" label="名称（英文）" prop="enentname" label-width="auto" borderBottom>
					<u-input v-model="formData.enentname" placeholder="请输入" border="none"></u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.opscope" label="经营范围" prop="opscope" required label-width="auto" borderBottom>
					<u--textarea v-model="formData.opscope" placeholder="食品生产、加工、经销及果酒、葡萄酒、饮料的销售。(依法须经批准的项目，经相关部门批准后方可开展经营活动)"></u--textarea>
				</u-form-item>
				<u-form-item v-if="formKeys.specmanagement" label="经营范围是否涉及国家规定实施的准入特别管理措施" prop="specmanagement" required label-width="auto" borderBottom>
					<u-radio-group v-model="formData.specmanagement" placement="row">
						<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
					</u-radio-group>
				</u-form-item>
				<template v-if="formData.specmanagement == '1'">
					<view class="textLength u-checkbox-group_wrap">
						<u-form-item v-if="formKeys.specmameasures" label="特别管理措施" prop="specmameasures" label-width="auto" borderBottom>
							<u-checkbox-group v-model="formData.specmameasures" placement="row">
								<u-checkbox :activeColor="bgColor" label="实物" v-for="ite,ind in 10" :key="ind"></u-checkbox>
							</u-checkbox-group>
						</u-form-item>
					</view>
					<u-form-item v-if="formKeys.listareas" label="符合条件的港澳投资者、服务提供者经营范围是否涉及内地与香港、澳门《cepa服务贸易协议》《cepa投资协议》负面清单内的领域" prop="listareas" required label-width="auto" borderBottom>
						<u-radio-group v-model="formData.listareas" placement="row">
							<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
						</u-radio-group>
					</u-form-item>
				</template>
				<view v-if="formKeys.listent" class="showHint_wrap">
				 	<u-form-item label="是否为上市公司" prop="listent" required label-width="auto" borderBottom>
				 		<u-radio-group v-model="formData.listent" placement="row">
				 			<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
				 		</u-radio-group>
				 	</u-form-item>
					<view
						slot="leftIcon" class="showHint" style="transform: translateX(-12rpx);"
						@click="$util.showModal({content:'根据公司发行股票实际情况填写，上市的证券市场选项可复选。非上市的公众公司是指在全国中小企业股份转让系统挂牌的公司。'})"
					>
						<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
					</view>
				</view>
				<u-form-item v-if="formKeys.listtype && formData.listent == '1'" label="上市公司类型" prop="listtype" required label-width="auto" borderBottom>
					<u-radio-group v-model="formData.listtype" placement="row">
						<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
					</u-radio-group>
				</u-form-item>
				<u-form-item v-if="formKeys.publiccompany && formData.listent == '0'" label="是否非上市的公众公司" prop="publiccompany" required label-width="auto" borderBottom>
					<u-radio-group v-model="formData.publiccompany" placement="row">
						<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
					</u-radio-group>
				</u-form-item>
				<u-form-item v-if="formKeys.funinstitutions" label="是否为功能性机构" prop="funinstitutions" required label-width="auto" borderBottom>
					<u-radio-group v-model="formData.funinstitutions" placement="row">
						<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
					</u-radio-group>
				</u-form-item>
				<u-form-item v-if="formKeys.funinsttype && formData.funinstitutions == '1'" label="功能性机构类型" prop="funinsttype" required label-width="auto" borderBottom>
					<u-radio-group v-model="formData.funinsttype" placement="row">
						<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
					</u-radio-group>
				</u-form-item>
				<view v-if="formKeys.rdcent" class="showHint_wrap">
				 	<u-form-item v-if="formKeys.rdcent" label="是否为研发中心" prop="rdcent" required label-width="auto" borderBottom>
				 		<u-radio-group v-model="formData.rdcent" placement="row">
				 			<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
				 		</u-radio-group>
				 	</u-form-item>
					<view
						slot="leftIcon" class="showHint" style="transform: translateX(-12rpx);"
						@click="$util.showModal({content:`研发中心是指从事自然科学及其相关科技领域的研究开发和实验发展 (包括为研发活动服务的中间试验)的机构。
						其中，独立法人研发中心，是指外国投资者以法人形式设立的研发中心; 非独立法人研发中心，是指外商投资企业以独立部门或分公司形式设立的研发中心，
						请分别填写分公司或内设部门研发中心的数量，至少为1。`})"
					>
						<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
					</view>
				</view>
				<!-- 此处有条件触发内容 -->
				<u-form-item v-if="formKeys.leindependentrd && formData.rdcent == '1'" label="是否是独立法人研发中心" prop="leindependentrd" required label-width="auto" borderBottom>
					<u-radio-group v-model="formData.leindependentrd" placement="row">
						<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
					</u-radio-group>
				</u-form-item>
				<!-- 上面为否时 -->
				<template v-if="formData.rdcent == '1' && formData.leindependentrd == '1'">
					<u-form-item v-if="formKeys.subcomrdcent" label="是否设立分公司研发中心" prop="subcomrdcent" required label-width="auto" borderBottom>
						<u-radio-group v-model="formData.subcomrdcent" placement="row">
							<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item v-if="formKeys.subcomrdcentnum && formData.subcomrdcent == '1'" label="设立分公司研发中心个数" prop="subcomrdcentnum" label-width="auto" borderBottom>
						<u-input v-model="formData.subcomrdcentnum" placeholder="请输入" border="none">
							<u--text
								text="个"
								slot="suffix"
							></u--text>
						</u-input>
					</u-form-item>
					<u-form-item v-if="formKeys.indeprddiv" label="是否内设独立研发部门" prop="indeprddiv" required label-width="auto" borderBottom>
						<u-radio-group v-model="formData.indeprddiv" placement="row">
							<u-radio v-for="item,index in stateRangesA" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item v-if="formKeys.rddivnum && formData.indeprddiv == '1'" label="内设独立研发部门个数" prop="rddivnum" label-width="auto" borderBottom>
						<u-input v-model="formData.rddivnum" placeholder="请输入" border="none">
							<u--text
								text="个"
								slot="suffix"
							></u--text>
						</u-input>
					</u-form-item>
				</template>
				
				<view class="u-radio-group_column_wrap">
					<u-form-item v-if="formKeys.foreigninvtype" label="外商投资性公司类型" prop="foreigninvtype" required label-width="auto" borderBottom>
						<u-radio-group v-model="formData.foreigninvtype" placement="column">
							<u-radio v-for="item,index in stateRangesB" :key="index" :label="item.text" :name="item.value" :activeColor="bgColor"></u-radio>
						</u-radio-group>
					</u-form-item>
				</view>
				<view v-if="formKeys.foreemnum" class="showHint_wrap">
				 	<u-form-item v-if="formKeys.foreemnum" label="外籍职工" prop="foreemnum" label-width="auto" borderBottom>
				 		<u-input v-model="formData.foreemnum" placeholder="请输入" border="none">
				 			<u--text
				 				text="人"
				 				slot="suffix"
				 			></u--text>
				 		</u-input>
				 	</u-form-item>
					<view
						slot="leftIcon" class="showHint" style="transform: translateX(-12rpx);"
						@click="$util.showModal({content:`在报告年度年末，在企业 (机构) 及其分支机构工作，并由企业 (机构) 支付劳动报酬的外国公民和华侨、台、港、澳人员。`})"
					>
						<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
					</view>
				</view>
				<view v-if="formKeys.uniaboempnum" class="showHint_wrap">
				 	<u-form-item v-if="formKeys.uniaboempnum" label="大学及以上学历" prop="uniaboempnum" label-width="auto" borderBottom>
				 		<u-input v-model="formData.uniaboempnum" placeholder="请输入" border="none">
				 			<u--text
				 				text="人"
				 				slot="suffix"
				 			></u--text>
				 		</u-input>
				 	</u-form-item>
					<view
						slot="leftIcon" class="showHint" style="transform: translateX(-12rpx);"
						@click="$util.showModal({content:`在报告年度年末，企业(机构) 及其分支机构中具有大专以上学历的从业人员数。`})"
					>
						<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
					</view>
				</view>
				<view v-if="formKeys.curyearsalary" class="showHint_wrap">
				 	<u-form-item v-if="formKeys.curyearsalary" label="本年职工薪酬" prop="curyearsalary" label-width="auto" borderBottom>
				 		<u-input v-model="formData.curyearsalary" placeholder="请输入" border="none">
				 			<u--text
				 				text="万(元)"
				 				slot="suffix"
				 			></u--text>
				 		</u-input>
				 	</u-form-item>
					<view
						slot="leftIcon" class="showHint" style="transform: translateX(-12rpx);"
						@click="$util.showModal({content:`在报告年度所厘的纳税年度，企业 (机构) 及其分支机构支付给在本企业(机构) 任职
						或者受雇的员工的所有现金形式或者非现金形式的劳动报酬包括基本工资、奖金、津贴、补贴、年终加薪、加班工资，
						以及与员工任职或者受雇有关的其他支出。以上列入企业的工资性支出。`})"
					>
						<u-icon name="question-circle" :color="bgColor" size="34rpx"></u-icon>
					</view>
				</view>
				<u-form-item v-if="formKeys.demdepauthnum" label="境内知识产权行政部门授权" prop="demdepauthnum" label-width="auto" borderBottom>
					<u-input v-model="formData.demdepauthnum" placeholder="请输入" border="none">
						<u--text
							text="项"
							slot="suffix"
						></u--text>
					</u-input>
				</u-form-item>
				<u-form-item v-if="formKeys.outdepauthnum" label="境外知识产权行政部门授权" prop="outdepauthnum" label-width="auto" borderBottom>
					<u-input v-model="formData.outdepauthnum" placeholder="请输入" border="none">
						<u--text
							text="项"
							slot="suffix"
						></u--text>
					</u-input>
				</u-form-item>
			</u-form>
			
		</view>
		<view class="submitBtn_bc"></view>
		<view class="submitBtn_ubtn">
			<u-button :disabled="!$util.submitState(year,state)" @click="submit()">提交</u-button>
		</view>
	</view>
</template>

<script>
export default {
	data(){
		return{
			minFormName: 'wsBaseinfo', //小表单类型名
			regnoInfo: this.$store.state.regnoInfo,
			year: '',
			state: '',
			bgColor: this.$config.bgColor,
			
			stateRangesA: [
				{text: '是',value: '1'},
				{text: '否',value: '0'}
			],
			stateRangesB: [
				{text: '外商投资的投资性公司',value: '1'},
				{text: '外商投资的创业投资企业',value: '2'},
				{text: '外商投资的以投资为主要业务合伙企业',value: '3'},
				{text: '不涉及以上类型',value: '4'}
			],
			formData: {
				installlocation: '',
				handlingsituation: '',
				illegalused: '',
				
				thesameasdeclare: '',
				recapitalise: '',
				isfixedassets: '',
				othermatters: '',
			},
			rules: {
				installlocation: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				handlingsituation: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				illegalused: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				
				thesameasdeclare: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				recapitalise: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				isfixedassets: {type:'number',required: true,message: '请选择',trigger: ['blur','change']},
				othermatters: {type:'string',required: true,message: '内容输入有误',trigger: ['blur','change']},
			},

			
		}
	},
	onLoad(option) {
		this.year = option.year;
		this.state = option.state;
		this.getFormKey();
		this.getFormData();
	},
	onReady() {
		this.$refs.uForm.setRules(this.rules)
	},
	methods:{
		// 获取小表单数据
		getFormData(){
			let url = this.$typeData.minFormUrl.get(this.minFormName);
			if(!url){
				uni.showModal({
					title: '暂无接口'
				})
				return;
			}
			this.$http.sendRequest({
				url: url,
				data: {
					regno: this.regnoInfo.regno,
					ancheyear: this.year
				}
			})
			.then(res=>{
				console.log('接口返回',res.data);
				let data = res.data;
				let keys = Object.keys(this.formKeys);
				keys.forEach(item=>{
					this.formData[item] = data[item];
				})
				console.log(789789,this.formData);
			})
			.catch(err=>{})
		},
		//获取小表单拥有字段
		getFormKey(){
			let formKeys = this.$util.getFormKeys(this.minFormName,this.regnoInfo.enttype);
			this.formKeys = formKeys;
			let keys = Object.keys(formKeys);
			keys.forEach(item=>{
				this.rules[item] = this.rulesAll[item];
			})
		},
		submit(){
			let _this = this;
			this.$refs.uForm.validate().then(res => {
				this.saveBtn();
			}).catch(errors => {
				this.$util.showToast({title:'请完善信息'})
			})
		},
		saveBtn(){
			let data = {
				regno: this.regnoInfo.regno,
				ancheyear: this.year,
			}
			data = this.$util.setSaveFormData(this.formKeys,data,this.formData);
			this.$http.sendRequest({
				url: '/annual/report/ws-baseinfo/update-wsbaseinfo',
				method: 'PUT',
				data: data
			})
			.then(res=>{
				this.setRecord();
			})
			.catch(err=>{})
		},
		
		
		
		//存一下记录
		setRecord(){
			let fillingItem = this.$minFormType.get(this.minFormName);
			this.$http.sendRequest({
				url: '/annual/report/record',
				method: 'POST',
				data: {
					regno: this.regnoInfo.regno,
					year: this.year,
					fillingItem: fillingItem,
					isImp: '0',
				},
				hideLoad: true,
			})
			.then(res=>{
				uni.navigateBack();
			})
			.catch(err=>{})
		},
		goPage(path){
			uni.navigateTo({
				url: path
			})
		},
	}
}
</script>

<style lang="scss">
.wrap{
	width: 100vw;
	min-height: 100vh;
	padding-top: 16rpx;
	box-sizing: border-box;
	position: relative;
	background-color: #FFF;
	
	.topBc{
		height: 10rpx;
		background-color: #F5F6F8;
	}
}

.content{
	padding: 30rpx 36rpx;
	background-color: #FFF;
	
	.title{
		color: #E4B269;
		font-size: 36rpx;
		font-weight: bold;
		border-left: 8rpx solid #E4B269;
		line-height: 40rpx;
		padding-left: 16rpx;
		margin-bottom: 30rpx;
		margin-top: 30rpx;
	}
	
	
}

.u-radio-group_column_wrap{
	.u-radio{
		margin-bottom: 10rpx;
	}
}
.u-checkbox-group_wrap{
	.u-checkbox-group{
		display: flex;
		flex-flow: wrap;
	}
	.u-checkbox{
		margin: 0 10rpx 10rpx;
	}
}
</style>